package com.ormlite.activity.tool;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class GuiUtils {

	private GuiUtils() {
		// no instance needed
	}

	public static void setDefaultEditText(Activity activity, int rId, Object text) {
		EditText editTitle = (EditText) activity.findViewById(rId);
		editTitle.setText(text.toString());
	}

	public static String getEditText(Activity activity, int rId) {
		EditText editTitle = (EditText) activity.findViewById(rId);
		return editTitle.getText().toString();
	}

	public static void setTextView(View view, int rId, Object text) {
		TextView textView = (TextView) view.findViewById(rId);
		textView.setText(text.toString());
	}

	public static void hookButton(Activity activity, int rId, View.OnClickListener concreteButton) {
		Button back = (Button) activity.findViewById(rId);
		back.setOnClickListener(concreteButton);
	}

	public static void hookButton(View view, int rId, View.OnClickListener concreteButton) {
		Button back = (Button) view.findViewById(rId);
		back.setOnClickListener(concreteButton);
	}

	public static void showAlertDialog(Context context, String message) {
		Builder alertDialog = new AlertDialog.Builder(context);
		alertDialog.setTitle("Warning!");
		alertDialog.setMessage(message);
		alertDialog.create().show();
	}
}
